package org.zfx.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * Rest公共返回方法
 */
@Data
@ApiModel("统一API响应结果封装")
public class Result implements Serializable {
    private static final long serialVersionUID = 6308315887056661996L;
    @ApiModelProperty(value = "成功失败的标志",required = true)
    private Integer code;
    @ApiModelProperty(value = "成功失败的响应信息",required = true)
    private String message;
    @ApiModelProperty(value = "成功失败的响应数据",required = false)
    private Object data;

    public Result setResult(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        return this;
    }

    public Result setResult(ResultCode resultCode,Object data) {
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        this.setData(data);
        return this;
    }
}